/*
 * FrameDialog.java
 * business
 *
 * Created by ChenTao on 2017/2/25.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.response.QueryFrameResponse;
import com.yidiandao.business.ui.widget.view.RatioLayout;
import com.yidiandao.business.utils.JumpUtils;

/**
 * 活动的Dialog
 */
public class FrameDialog extends Dialog implements View.OnClickListener {

    private Activity mActivity;

    private ImageView mIvFrameClose;

    private ImageView mIvFrameImage;

    private RatioLayout mFrameRatio;

    private QueryFrameResponse.Frame mFrameData;

    public FrameDialog(Context context) {
        super(context, R.style.ThemeActivityDialog);
        mActivity = (Activity) context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_frame);

        mIvFrameClose = (ImageView) findViewById(R.id.iv_frame_close);
        mIvFrameImage = (ImageView) findViewById(R.id.iv_frame_image);
        mFrameRatio = (RatioLayout) findViewById(R.id.frame_ratio);

        mIvFrameClose.setOnClickListener(this);
        mIvFrameImage.setOnClickListener(this);
    }

    public void setFrameImageRatio(float ratio) {
        mFrameRatio.setRatio(ratio);
    }

    public void setFrameImage(Bitmap bitmap) {
        mIvFrameImage.setImageBitmap(bitmap);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_frame_close:
                dismiss();
                break;
            case R.id.iv_frame_image:
                JumpUtils.clickHomeBigImage(mFrameData, mActivity);
                dismiss();
                break;
        }
    }

    public void setFrameData(QueryFrameResponse.Frame frame) {
        mFrameData = frame;
    }
}
